package cn.xjt.hello;

/**
 * 例子：创建三个窗口买票，总票数为100张
 * 使用继承Thread类的方式做的
 * @author xujiangtao
 * @create 2020-07-31-10:34
 */
class windows extends thread{
    private static int ticket=100;
    @Override
    public void run() {
        while(true)
        {
            if(ticket>0)
            {
                System.out.println(getName()+":买票;\t票号:"+ticket);
                ticket--;
            }else{
                break;
            }
        }
    }
}
public class windowTest {
    public static void main(String[] args) {

        windows wt1 = new windows();
        windows wt2 = new windows();
        windows wt3 = new windows();
        wt1.setPriority(5);
        wt1.setName("线程一");
        wt2.setName("线程二");
        wt3.setName("线程三");
        wt1.start();
        wt2.start();
        wt3.start();

    }
}
